---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: speaker
  namespace: d8-{{ .Chart.Name }}
  {{- include "helm_lib_module_labels" (list . (dict "app" "speaker")) | nindent 2 }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: d8:metallb:speaker
  {{- include "helm_lib_module_labels" (list . (dict "app" "speaker")) | nindent 2 }}
rules:
  - apiGroups:
      - ""
    resources:
      - services
      - endpoints
      - nodes
      - namespaces
    verbs:
      - get
      - list
      - watch
  - apiGroups:
      - discovery.k8s.io
    resources:
      - endpointslices
    verbs:
      - get
      - list
      - watch
  - apiGroups:
      - ""
    resources:
      - events
    verbs:
      - create
      - patch
  - apiGroups:
      - policy
    resourceNames:
      - speaker
    resources:
      - podsecuritypolicies
    verbs:
      - use
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: d8:metallb:speaker
  {{- include "helm_lib_module_labels" (list . (dict "app" "speaker")) | nindent 2 }}
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: d8:metallb:speaker
subjects:
  - kind: ServiceAccount
    name: speaker
    namespace: d8-{{ .Chart.Name }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: speaker
  {{- include "helm_lib_module_labels" (list . (dict "app" "speaker")) | nindent 2 }}
  namespace: d8-{{ .Chart.Name }}
rules:
  - apiGroups:
      - ""
    resources:
      - pods
    verbs:
      - list
  - apiGroups:
      - ""
    resources:
      - secrets
      - configmaps
    verbs:
      - get
      - list
      - watch
  - apiGroups:
      - metallb.io
    resources:
      - addresspools
    verbs:
      - get
      - list
      - watch
  - apiGroups:
      - metallb.io
    resources:
      - bfdprofiles
    verbs:
      - get
      - list
      - watch
  - apiGroups:
      - metallb.io
    resources:
      - bgppeers
    verbs:
      - get
      - list
      - watch
  - apiGroups:
      - metallb.io
    resources:
      - l2advertisements
    verbs:
      - get
      - list
      - watch
  - apiGroups:
      - metallb.io
    resources:
      - bgpadvertisements
    verbs:
      - get
      - list
      - watch
  - apiGroups:
      - metallb.io
    resources:
      - ipaddresspools
    verbs:
      - get
      - list
      - watch
  - apiGroups:
      - metallb.io
    resources:
      - communities
    verbs:
      - get
      - list
      - watch

---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  {{- include "helm_lib_module_labels" (list . (dict "app" "speaker")) | nindent 2 }}
  name: speaker
  namespace: d8-{{ .Chart.Name }}
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: speaker
subjects:
  - kind: ServiceAccount
    name: speaker
    namespace:  d8-{{ .Chart.Name }}
